package org.finesys.chat.core.base.embedding.filter;

import org.finesys.chat.core.base.embedding.filter.compairson.*;
import org.finesys.chat.core.base.embedding.filter.logical.NotFilter;
import org.finesys.common.core.util.ValidationUtil;

import java.util.Arrays;

public class MetadataFilterBuilder {
    private final String key;

    public MetadataFilterBuilder(String key) {
        this.key = ValidationUtil.ensureNotBlank(key, "key");
    }

    public static MetadataFilterBuilder of(String key) {
        return new MetadataFilterBuilder(key);
    }

    public Filter equal(Object value) {
        return new EqualFilter(this.key, value);
    }

    public Filter notEqual(Object value) {
        return new NotFilter(new EqualFilter(this.key, value));
    }

    public Filter greaterThan(Object value) {
        return new GreaterThanFilter(this.key, value);
    }

    public Filter greaterThanOrEqual(Object value) {
        return new GreaterThanEqualFilter(this.key, value);
    }

    public Filter lessThan(Object value) {
        return new LessThanFilter(this.key, value);
    }

    public Filter lessThanOrEqual(Object value) {
        return new LessThanEqualFilter(this.key, value);
    }


    public Filter in(Object... values) {
        return new InFilter(this.key, Arrays.asList(values));
    }

    public Filter notIn(Object... values) {
        return new NotInFilter(this.key, Arrays.asList(values));
    }

    public Filter between(Object min, Object max) {
        return greaterThanOrEqual(min).and(lessThanOrEqual(max));
    }

    public Filter like(Object value) {
        return new LikeFilter(this.key, value);
    }
}
